<?php

$link = "";

$nbPages = 1;
if($comment[ 'record_model' ] == 'News' || $comment[ 'record_model' ] == 'Event'){ //News or events
    $nbPages = ceil($comment['nb_comments'] / sfConfig::get('app_vjCommentPlugin_max_per_page', 5));

    $crypt = vjComment::getFormName($comment[ 'record_model' ].$comment[ 'id' ]);
    $array_record_id[$comment[ 'record_model' ]][$comment[ 'id' ]] = isset($array_record_id[$comment[ 'record_model' ]][$comment[ 'id' ]]) ? $array_record_id[$comment[ 'record_model' ]][$comment[ 'id' ]]+1 : 0;

    $numPage = $nbPages;
    if(($comment['nb_comments'] - $array_record_id[$comment[ 'record_model' ]][$comment[ 'id' ]])%sfConfig::get('app_vjCommentPlugin_max_per_page', 5) == 0){
        $numPage = $nbPages - (ceil($array_record_id[$comment[ 'record_model' ]][$comment[ 'id' ]] / sfConfig::get('app_vjCommentPlugin_max_per_page', 5)));
    }

    if($comment[ 'record_model' ] == 'News'){
        $link = commentTools::rewriteUrlForPage('@news_show_comments?title_slug=' . $comment['slug'], $numPage, $crypt);
    }else if($comment[ 'record_model' ] == 'Event'){
        $link = commentTools::rewriteUrlForPage('@event_show_comments?title_slug=' . $comment['slug'], $numPage, $crypt);
    }
}else if($comment[ 'record_model' ] == 'Forum'){ // Forums
    $nbPages = ceil($comment['nb_comments'] / sfConfig::get('app_sfSimpleForumPlugin_max_per_page', 10));
    $link = '@forum_message?id=' . $comment['id'];
}

echo $link;
?>
